package com.sumainfor.wx.system.gmio.service;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.wx.system.feign.BaseFeignEpc;
import com.sumainfor.wx.system.feign.BaseFeignMarket;
import com.sumainfor.wx.system.feign.BaseFeignZuul;
import com.sumainfor.wx.system.gmio.dao.WorkbenchMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Meng
 * @ClassName WorkbenchController
 * @date 2019/8/8 10:31
 * @description: TODO 微信端服务管家工作台
 */
@Service
public class WorkbenchService {

    @Autowired
    private WorkbenchMapper workbenchMapper;

    @Autowired
    private BaseFeignZuul feignZuul;

    @Autowired
    private BaseFeignMarket feignMarket;

    @Autowired
    private BaseFeignEpc feignEpc;

    /**
     * @Description //TODO 获取工作台续租和巡房验房数量
     * @return java.util.Map<java.lang.String,java.lang.Integer>
     * @Param [userId]
     * @Date 2019/8/12 10:31
     **/
    public Map<String, Integer> getReletAndCheckRoom(String userId) {

        Map<String, Integer> map = new HashMap<>();
        //获取本日续租和本月续租的房源数量
        Integer reletCountDay = workbenchMapper.getReletCountDay(userId);
        Integer reletCountMonth = workbenchMapper.getReletCountMonth(userId);
        //查询本月巡房记录数量
        Integer lookHouseCount = workbenchMapper.getLookHouseCount(userId);
        //查询管家关联的所有房源id
        List<String> houIds = workbenchMapper.getHouIdsBySysUserId(userId);
        //查询本月新房验房记录数量
        Integer chechHouseCount = workbenchMapper.getChechHouseCount(houIds);
        //查询本月退房验收的数量, 缺失
        //封装数据
        map.put("reletCountDay", reletCountDay);
        map.put("reletCountMonth", reletCountMonth);
        map.put("lookHouseCount", lookHouseCount);
        map.put("chechHouseCount", chechHouseCount);
        return map;
    }

    /**
     * @Description //TODO 获取工作台消息通知
     * @return com.sumainfor.common.util.JsonResult
     * @Param [userId]
     * @Date 2019/8/12 10:32
     **/
    public JsonResult getRollMessage(String userId) {

        Map<String, Object> param = new HashMap<>();
        List<String> meList = new ArrayList<>();
        meList.add("10");
        //角色id列表
        param.put("MeList", meList);
        //0列表查询, 1通知查询, 只查两条
        param.put("OpenPaging", 0);
        //分页, 查10条
        param.put("pageno", 1);
        param.put("pagesize", 10);
        JsonResult sysMessageList = feignZuul.getSysMessageList(param);
        return sysMessageList;

    }

    /**
     * @Description //TODO 查询退租待验收列表
     * @return com.sumainfor.common.util.JsonResult
     * @Param [params]
     * @Date 2019/8/12 10:47
     **/
    public JsonResult getHouConPactList(Map<String, Object> params) {
        //调用市场部的退租待验收接口
        return feignMarket.getHouConPactList(params);
    }

    /**
     * @Description //TODO 查询新房待验收列表
     * @return com.sumainfor.common.util.JsonResult
     * @Param [params]
     * @Date 2019/8/12 10:58
     **/
    public JsonResult getHoDecoratePiList(Map<String, Object> params) {
        //调用工程部的新房待验收接口
        return feignEpc.getHoDecoratePiList(params);
    }
}
